using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MobileWebsiteGenerator.Entities;
using MobileWebsiteGenerator;

namespace MobileWebsiteGenerator.Areas.Admin.Controllers
{
    public class WebsitePagesController : Controller
    {
        private Mobile_appContext context = new Mobile_appContext();

        //
        // GET: /WebsitePages/

        public ViewResult Index()
        {
            return View(context.WebsitePages.ToList());
        }

        //
        // GET: /WebsitePages/Details/5

        public ViewResult Details(int id)
        {
            WebsitePages websitepages = context.WebsitePages.Single(x => x.ID == id);
            return View(websitepages);
        }

        //
        // GET: /WebsitePages/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /WebsitePages/Create

        [HttpPost]
        public ActionResult Create(WebsitePages websitepages)
        {
            if (ModelState.IsValid)
            {
                context.WebsitePages.Add(websitepages);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(websitepages);
        }

        //
        // GET: /WebsitePages/Edit/5

        public ActionResult Edit(int id)
        {
            WebsitePages websitepages = context.WebsitePages.Single(x => x.ID == id);
            return View(websitepages);
        }

        //
        // POST: /WebsitePages/Edit/5

        [HttpPost]
        public ActionResult Edit(WebsitePages websitepages)
        {
            if (ModelState.IsValid)
            {
                context.Entry(websitepages).State = EntityState.Modified;
                context.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(websitepages);
        }

        //
        // GET: /WebsitePages/Delete/5

        public ActionResult Delete(int id)
        {
            WebsitePages websitepages = context.WebsitePages.Single(x => x.ID == id);
            return View(websitepages);
        }

        //
        // POST: /WebsitePages/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            WebsitePages websitepages = context.WebsitePages.Single(x => x.ID == id);
            context.WebsitePages.Remove(websitepages);
            context.SaveChanges();
            return RedirectToAction("Index");
        }
    }
}